<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>FileHelpers Library - Marcos Meli</TITLE>
<LINK href="/favicon.ico" rel="SHORTCUT ICON"><LINK 
href="global.css" type=text/css 
rel=stylesheet>
<link type="text/css" rel="stylesheet" href="SyntaxHighlighter.css"></link>

<meta NAME="Description"        content="An easy to use .NET library to read/write data from fixed length or delimited files or streams. It has support to import/export data from different data sources." />
<meta name="Author"             content="Marcos Meli" />
<meta NAME="keywords" Content="filehelpers,CSV,Marcos_Meli,C#,free,opensource,Devoo.net,Delimited Files,Import/Export">
<meta NAME="Copyright" CONTENT="Copyright 2005-07 to Marcos Meli - www.Devoo.net. All Rights Reserved.">

<style type="text/css">
<!--
.style1 {color: #FFFFFF}
-->
</style>
</HEAD>
<BODY   text=black vLink=purple aLink=red link=blue 
bgColor=white leftMargin=0 topMargin=0>

		{$HEADER$}


<table width="100%" cellpadding="5" cellspacing="5">
<tr><td><div id=contentdiv> 
  <h2>FileDiffEngine Example </h2>
  <blockquote>
          <p>The idea of this engine is to parse files with the same record layout and do some diff over the records.</p>

      <p>
          To work with the DiffEngine your record must implement the interface <a href="FielHelpers.IComparableRecord.html">IComparableRecord</a> </p>
          <blockquote>
<textarea name="code" class="c#">

	[DelimitedRecord("|")]
	public class Customers: IComparableRecord
	{
		public string CustomerID;
		public string CompanyName;
		public string ContactName;
		public string ContactTitle;
		public string Address;
		public string City;
		public string Country;

		public bool IsEqualRecord(object record)
		{
			Customers rec = (Customers) record;
			return this.CustomerID == rec.CustomerID;
		}
	}
		
</textarea>

          </blockquote>
      <p>
          <b>For example if you want to get the new customers based on two customers files you can use:</b></p>
          <blockquote>
<textarea name="code" class="c#">

		engine = new FileDiffEngine(typeof (Customers));

		Customers[] res = engine.OnlyNewRecords("customersold.txt", "customernew.txt") as Customers[];
		
</textarea>

          </blockquote>
          <p>
              In the res array you have all the records in the file customersnew.txt that dont exists in the customersold.txt file</p>

      <p>
          <b>Now you may need to extract the records that apeer in both files:</b></p>
          <blockquote>
<textarea name="code" class="c#">

		engine = new FileDiffEngine(typeof (Customers));

		Customers[] res = engine.OnlyDuplicatedRecords("customersold.txt", "customernew.txt") as Customers[];
		
</textarea>

          </blockquote>
          <p>
              In the res array you have all the records in the file customersnew.txt that exists in the customersold.txt file</p>
       

      <p>
          <b>And how many lines you need to write the diff to other file... you are right one line !!</b></p>
          <blockquote>
<textarea name="code" class="c#">

		engine = new FileDiffEngine(typeof (Customers));

		engine.WriteNewRecords("customersold.txt", "customernew.txt", "onlynews.txt");
		
</textarea>

          </blockquote>
          </blockquote>
          
          
      <p>
         <b>Enjoy it !!!</b></p>
  </blockquote>

		{$FOOTER$}
</tr>
</table>


</BODY></HTML>
